package com.mgiandia.library.dao;

import java.util.List;

import com.mgiandia.library.domain.core.Borrower;
import com.mgiandia.library.domain.core.Item;
import com.mgiandia.library.domain.core.Loan;

public class MemoryInitializer extends Initializer {

    @Override
    protected void eraseData() {
        DAOFactory factory = DAOFactory.getFactory();        
        List<Borrower> allBorrowers = factory.getBorrowerDAO().findAll();
        for(Borrower borrower : allBorrowers) {
            factory.getBorrowerDAO().delete(borrower);
        }
            
        List<Item> allItems = factory.getItemDAO().findAll();        
        for(Item item : allItems) {
            factory.getItemDAO().delete(item);
        }
        
        List<Loan> allLoans = factory.getLoanDAO().findAll(); 
        for(Loan loan : allLoans) {
            factory.getLoanDAO().delete(loan);
        }    
    }
    
}
